package com.xlf.strategy.impl;

import com.xlf.strategy.mode.AbstractUploadStrategyImpl;
import com.xlf.utils.file.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Service("ossUploadStrategyImpl")
public class OssUploadStrategyImpl extends AbstractUploadStrategyImpl {


    @Autowired
    private QiniuUtils qiniuUtils;
    @Override
    public Boolean exists(String filePath) {
        return qiniuUtils.exists(filePath);
    }

    @Override
    public void upload(String path, String fileName, MultipartFile file) throws IOException {
        //这里不用将域名拼进去 会自己搞
        qiniuUtils.upload(file,path+fileName);
    }

    @Override
    public String getFileAccessUrl(String filePath) {
        return qiniuUtils.url+filePath;
    }
}
